import {NgModule} from '@angular/core';
import {Routes, RouterModule} from '@angular/router';
import {ConfigurationGuard} from "./pages/shared/configuration/guard/configuration.guard";
import {LayoutComponent} from "./pages/shared/layout/layout.component";

const routes: Routes = [
  {path: '', pathMatch: 'full', redirectTo: '/welcome'},
  {
    path: '',
    component: LayoutComponent,
    children: [
      {
        path: 'welcome',
        canActivateChild: [ConfigurationGuard],
        loadChildren: () => import('./pages/welcome/welcome.module').then(m => m.WelcomeModule)
      },
      {
        path: 'user',
        canActivateChild: [ConfigurationGuard],
        loadChildren: () => import('./pages/modules/user/user.module').then(m => m.UserModule)
      },
      {
        path: 'privilege',
        canActivateChild: [ConfigurationGuard],
        loadChildren: () => import('./pages/modules/privilege/privilege.module').then(m => m.PrivilegeModule)
      },
      {
        path: 'role',
        canActivateChild: [ConfigurationGuard],
        loadChildren: () => import('./pages/modules/role/role.module').then(m => m.RoleModule)
      },
    ]
  },
  {
    path: 'configuration',
    loadChildren: () => import('./pages/shared/configuration/configuration.module').then(m => m.ConfigurationModule)
  },
];

@NgModule({
  imports: [RouterModule.forRoot(routes)],
  exports: [RouterModule]
})
export class AppRoutingModule {
}
